package com.zhl.media.commonres.dialog;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import com.zhl.media.commonres.R;


public class DeleteDialog extends Dialog {
    String content;
    private TextView tvHint,tvSure,tvCancel;
    public DeleteDialog(@NonNull Context context,String content) {
        super(context);
        this.content = content;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Window window = getWindow();
        window.setGravity(Gravity.CENTER);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_delete_hallpic, null);
        tvHint = view.findViewById(R.id.tv_hint);
        tvSure = view.findViewById(R.id.id_sure);
        tvCancel = view.findViewById(R.id.id_cancel);
        tvHint.setText(content);
        tvCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        tvSure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener!=null) {
                    listener.delete();
                }
            }
        });
        setContentView(view);
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        getWindow().setAttributes(lp);
    }

    DeleteHallListener listener;

    public void setListener(DeleteHallListener listener) {
        this.listener = listener;
    }

    public interface DeleteHallListener {
        void delete();
    }
}
